<template>
  <div class="container-content detail">
    <div
      class="detail-bg"
      :style="{ background: $store.state.settings.theme }"
    ></div>
    <div class="detail-container">
      <el-row>
        <el-col :span="24">
          <h3 class="panel-title"></h3>
        </el-col>
      </el-row>
      <el-descriptions
        class="detail-descriptions"
        title="开票详情"
        :column="1"
        border
        colon
      >
        <template slot="extra">
          <el-button
            type="primary"
            size="small"
            icon="el-icon-edit"
            plain
            @click="editItem"
          ></el-button>
          <el-button
            type="danger"
            size="small"
            icon="el-icon-delete"
            plain
            @click="deleteItem"
          ></el-button>
        </template>
        <el-descriptions-item>
          <template slot="label"> 账号 </template>
          {{ formObject.account || "--" }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 供应商 </template>
          {{ formObject.supplierId || "--" }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 开票公司名称 </template>
          {{ formObject.invoicingCompany || "--" }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 开户银行 </template>
          {{ formObject.openingBank || "--" }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 开户名称 </template>
          {{ formObject.openingName || "--" }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 纳税人识别号 </template>
          {{ formObject.taxpayerIdNum || "--" }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 期初未开票金额 </template>
          {{ formObject.uninvoicedAmount || "--" }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label"> 备注 </template>
          {{ formObject.remarks || "--" }}
        </el-descriptions-item>
      </el-descriptions>
    </div>
  </div>
</template>
<script>
import { getDetailInvoice, deleteInvoiceList } from "@/api/system/contract";
export default {
  data() {
    return {
      formObject: {
        account: "",
        changeTime: "",
        createTime: "",
        invoicingCompany: "",
        openingAddress: "",
        openingBank: "",
        openingName: "",
        supplierId: "",
        taxpayerIdNum: "",
        uninvoicedAmount: "",
      },
    };
  },
  methods: {
    getData(id) {
      getDetailInvoice(id).then((res) => {
        if (res.code === 200) {
          let data = res.data;
          Object.keys(this.formObject).forEach((key) => {
            this.formObject[key] = data[key];
          });
        }
      });
    },
    editItem() {
      this.$router.push({
        path: "/Contract/EditInvoicing",
        query: { id: this.$route.query.id },
      });
    },
    deleteItem() {
      this.$confirm("请确定要删除此方案吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          deleteInvoiceList(this.$route.query.id).then((res) => {
            if (res.code === 200) {
              this.$message({
                type: "success",
                message: "删除成功!",
              });
              this.$router.push({
                path: "/Contract/Invoicing",
              });
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
  created() {
    this.getData(this.$route.query.id);
  },
};
</script>
<style lang="scss" scoped>
.detail-bg {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  height: 200px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding-left: 10px;
  padding-right: 10px;
}
.detail {
  background: #f1f4f5;
  height: 100%;
}
.detail-container {
  width: 98%;
  margin: 1%;
  background: #fff;
  z-index: 3;
  position: relative;
  border-radius: 10px;
  padding: 20px;
}
.detail-descriptions {
  padding-left: 40px;
  padding-right: 40px;
}
::v-deep .el-descriptions-item__label.is-bordered-label {
  width: 20%;
}
</style>
